#include <allegro.h>
#include <stdlib.h>

void docircle(BITMAP *bmp, int x, int y, int color){
    putpixel(bmp, x ,y ,color);
    putpixel(bmp, x+1,y+1, color);
    rest(1);
}

int main(void){

    int red,green,blue,color;

    allegro_init();
    install_keyboard();
    install_timer();

    int ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
    if(ret != 0){
        allegro_message(allegro_error);
        return 1;
    }

    textprintf_ex(screen,font,0,0,15,-1,"Spline Program - %dx%d - press ESC to quit.", SCREEN_W, SCREEN_H);

    int points[8] = {0,240,300,0,200,0,639,240};
    int y1 = 0;
    int y2 = SCREEN_H;
    int dir1 = 10;
    int dir2 = -10;

    while(!key[KEY_ESC]){
        y1 += dir1;
        if(y1>SCREEN_H){
            dir1 = -10;
        }
        if(y1 < 0)
            dir1 = 10;
        points[3] = y1;

        y2 += dir2;
        if(y2++ > SCREEN_H){
            dir2 = -10;
        }
        if(y2<0)
            dir2 = 10;
        points[5] = y2;

        spline(screen,points,15);
        rest(30);
        spline(screen,points,0);

    }
    allegro_exit();
    return 0;

}
END_OF_MAIN()
